﻿using System;
using System.Collections.Specialized;
using System.IO;
using System.Net;

namespace MinorAspNetCore.Server
{
    public class MinorHttpListenerFeature : IMinorHttpRequestFeature, IMinorHttpResponseFeature
    {
        private readonly HttpListenerContext _context;

        public MinorHttpListenerFeature(HttpListenerContext context) => _context = context;

        Uri IMinorHttpRequestFeature.Url => _context.Request.Url;

        NameValueCollection IMinorHttpRequestFeature.Headers => _context.Request.Headers;

        NameValueCollection IMinorHttpResponseFeature.Headers => _context.Response.Headers;

        Stream IMinorHttpRequestFeature.Body => _context.Request.InputStream;

        Stream IMinorHttpResponseFeature.Body => _context.Response.OutputStream;

        int IMinorHttpResponseFeature.StatusCode
        {
            get => _context.Response.StatusCode;
            set => _context.Response.StatusCode = value;
        }
    }
}